﻿<%@ Page Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master" AutoEventWireup="true"
    CodeFile="ViewCarMakeModel.aspx.cs" MaintainScrollPositionOnPostback="true" Inherits="Admin_car_insurance_ViewCarMakeModel" %>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
    <div class="contents">
        <table width="100%" cellpadding="3" cellspacing="0" border="0">
            <tr>
                <td colspan="2">
                    <h1>View Car Model</h1>
                </td>
            </tr>
            <tr>
                <td>
                    Car Make : 
                    <asp:TextBox ID="txtSearchCarMake" runat="server"></asp:TextBox> 
                    <asp:Button ID="btnSearchCarMake" runat="server" Text="Search" OnClick="btnSearchCarMake_Click" />
                </td>
                <td width="30%" align="right" style="text-align:right;">
                    <asp:Button ID="btnCreatNewCarMake" runat="server" Text="Create New Car Make" OnClick="btnCreatNewCarMake_Click" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:GridView ID="grvCarMake" runat="server" AllowPaging="True" AllowSorting="True"
                        AutoGenerateColumns="False" Cellspacing="3" CellPadding="3" Width="100%" DataKeyNames="CarMakeId"
                        DataSourceID="sqlDsCarMake" EmptyDataText="There are no data records to display."
                        CssClass="admin_gridstyle" PagerStyle-CssClass="pgr"  GridLines="None">
                        <Columns>
                            <asp:BoundField DataField="CarMakeAutoId" HeaderText="CarMakeAutoId" InsertVisible="False"
                                ReadOnly="True" SortExpression="CarMakeAutoId" Visible="False" />
                            <asp:BoundField DataField="CarMakeId" HeaderText="CarMakeId" ReadOnly="True" SortExpression="CarMakeId" />
                            <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                            <asp:CheckBoxField DataField="Status" HeaderText="Status" SortExpression="Status" />
                            <asp:CommandField ShowSelectButton="True" />
                            <asp:BoundField DataField="RefCEUserId" HeaderText="RefCEUserId" SortExpression="RefCEUserId"
                                Visible="False" />
                            <asp:BoundField DataField="CreatedDate" HeaderText="CreatedDate" SortExpression="CreatedDate"
                                Visible="False" />
                            <asp:BoundField DataField="ModifiedDate" HeaderText="ModifiedDate" SortExpression="ModifiedDate"
                                Visible="False" />
                        </Columns>
                        <FooterStyle />
                        <PagerStyle />
                        <SelectedRowStyle />
                        <HeaderStyle CssClass="admin_gridheader" />
                        <EditRowStyle />
                        <AlternatingRowStyle CssClass="admin_gridodd" />
                        <RowStyle CssClass="admin_grideven" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="sqlDsCarMake" runat="server" ConnectionString="<%$ ConnectionStrings:CX_DBConnectionString %>"
                        DeleteCommand="DELETE FROM [tblCarMakeInfo] WHERE [CarAutoId] = @CarAutoId" InsertCommand="INSERT INTO [tblCarMakeInfo] ([CarMakeId], [Description], [Status], [RefCEUserId], [CreatedDate], [Modified]) VALUES (@CarMakeId, @Description, @Status, @RefCEUserId, @CreatedDate, @Modified)"
                        ProviderName="<%$ ConnectionStrings:CX_DBConnectionString.ProviderName %>" SelectCommand="SELECT [CarMakeAutoId], [CarMakeId], [Description], [Status], [RefCEUserId], [CreatedDate], [ModifiedDate] FROM [tblCarMakeInfo] Where [Description] Like '%' + isnull(@Description,'%') + '%' Order By [Description]"
                        UpdateCommand="UPDATE [tblCarMakeInfo] SET [CarMakeId] = @CarMakeId, [Description] = @Description, [Status] = @Status, [RefCEUserId] = @RefCEUserId, [CreatedDate] = @CreatedDate, [Modified] = @Modified WHERE [CarAutoId] = @CarAutoId">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="txtSearchCarMake" ConvertEmptyStringToNull="False"
                                DefaultValue="%" Name="Description" PropertyName="Text" />
                        </SelectParameters>
                        <DeleteParameters>
                            <asp:Parameter Name="CarAutoId" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="CarMakeId" Type="Int32" />
                            <asp:Parameter Name="Description" Type="String" />
                            <asp:Parameter Name="Status" Type="Boolean" />
                            <asp:Parameter Name="RefCEUserId" Type="Int64" />
                            <asp:Parameter Name="CreatedDate" Type="DateTime" />
                            <asp:Parameter Name="Modified" Type="DateTime" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="CarMakeId" Type="Int32" />
                            <asp:Parameter Name="Description" Type="String" />
                            <asp:Parameter Name="Status" Type="Boolean" />
                            <asp:Parameter Name="RefCEUserId" Type="Int64" />
                            <asp:Parameter Name="CreatedDate" Type="DateTime" />
                            <asp:Parameter Name="Modified" Type="DateTime" />
                            <asp:Parameter Name="CarAutoId" Type="Int32" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td>
                    Car Model :  
                    <asp:TextBox ID="txtCarModelSearch" runat="server"></asp:TextBox>
                    <asp:Button ID="btnSearchCarModel" runat="server" Text="Search" />
                </td>
                <td width="30%" align="right" style="text-align:right;">
                    <asp:Button ID="btnCreatNewCarModel" runat="server" Text="Create New Car Model" OnClick="btnCreatNewCarModel_Click" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:GridView ID="grvCarModel" runat="server" AllowPaging="True" AllowSorting="True"
                        AutoGenerateColumns="False" Cellspacing="3" CellPadding="3" Width="100%" DataKeyNames="CarMakeId,CarModelId"
                        DataSourceID="sqlDsCarModel" EmptyDataText="There are no data records to display."
                        CssClass="admin_gridstyle" PagerStyle-CssClass="pgr"  GridLines="None" OnSelectedIndexChanged="grvCarModel_SelectedIndexChanged">
                        <Columns>
                            <asp:BoundField DataField="MakeModelId" HeaderText="MakeModelId" ReadOnly="True"
                                SortExpression="MakeModelId" Visible="False" />
                            <asp:BoundField DataField="CarModelId" HeaderText="CarModelId" SortExpression="CarModelId" />
                            <asp:BoundField DataField="CarMakeId" HeaderText="CarMakeId" SortExpression="CarMakeId" />
                            <asp:BoundField DataField="CarCode" HeaderText="CarCode" SortExpression="CarCode" />
                            <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                            <asp:BoundField DataField="Body" HeaderText="Body" SortExpression="Body" />
                            <asp:BoundField DataField="CC" HeaderText="CC" SortExpression="CC" />
                            <asp:CheckBoxField DataField="Status" HeaderText="Status" SortExpression="Status" />
                            <asp:CommandField SelectText="Edit" ShowSelectButton="True" />
                            <asp:BoundField DataField="RefCEUserId" HeaderText="RefCEUserId" SortExpression="RefCEUserId"
                                Visible="False" />
                            <asp:BoundField DataField="CreatedDate" HeaderText="CreatedDate" SortExpression="CreatedDate"
                                Visible="False" />
                            <asp:BoundField DataField="ModifiedDate" HeaderText="ModifiedDate" SortExpression="ModifiedDate"
                                Visible="False" />
                        </Columns>
                        <FooterStyle />
                        <PagerStyle />
                        <SelectedRowStyle />
                        <HeaderStyle CssClass="admin_gridheader" />
                        <EditRowStyle />
                        <AlternatingRowStyle CssClass="admin_gridodd" />
                        <RowStyle CssClass="admin_grideven" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="sqlDsCarModel" runat="server" ConnectionString="<%$ ConnectionStrings:CX_DBConnectionString %>"
                        DeleteCommand="DELETE FROM [tblCarModelInfo] WHERE [MakeModelId] = @MakeModelId"
                        InsertCommand="INSERT INTO [tblCarModelInfo] ([CarModelId], [CarMakeId], [CarCode], [Description], [Body], [CC], [Status], [RefCEUserId], [CreatedDate], [Modified]) VALUES (@CarModelId, @CarMakeId, @CarCode, @Description, @Body, @CC, @Status, @RefCEUserId, @CreatedDate, @Modified)"
                        ProviderName="<%$ ConnectionStrings:CX_DBConnectionString.ProviderName %>" SelectCommand="SELECT [MakeModelId], [CarModelId], [CarMakeId], [CarCode], [Description], [Body], [CC], [Status], [RefCEUserId], [CreatedDate], [ModifiedDate] FROM [tblCarModelInfo]
            WHERE [CarMakeId] = @CarMakeId AND ([Description] Like '%' + isnull(@Description,'%') + '%')
            Order By [CarMakeId], [CarModelId], [Description]" UpdateCommand="UPDATE [tblCarModelInfo] SET [CarModelId] = @CarModelId, [CarMakeId] = @CarMakeId, [CarCode] = @CarCode, [Description] = @Description, [Body] = @Body, [CC] = @CC, [Status] = @Status, [RefCEUserId] = @RefCEUserId, [CreatedDate] = @CreatedDate, [Modified] = @Modified WHERE [MakeModelId] = @MakeModelId">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="grvCarMake" Name="CarMakeId" PropertyName="SelectedValue" />
                            <asp:ControlParameter ControlID="txtCarModelSearch" ConvertEmptyStringToNull="False"
                                DefaultValue="%" Name="Description" PropertyName="Text" />
                        </SelectParameters>
                        <DeleteParameters>
                            <asp:Parameter Name="MakeModelId" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="CarModelId" Type="Int32" />
                            <asp:Parameter Name="CarMakeId" Type="Int32" />
                            <asp:Parameter Name="CarCode" Type="String" />
                            <asp:Parameter Name="Description" Type="String" />
                            <asp:Parameter Name="Body" Type="String" />
                            <asp:Parameter Name="CC" Type="String" />
                            <asp:Parameter Name="Status" Type="Boolean" />
                            <asp:Parameter Name="RefCEUserId" Type="Int64" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="CarModelId" Type="Int32" />
                            <asp:Parameter Name="CarMakeId" Type="Int32" />
                            <asp:Parameter Name="CarCode" Type="String" />
                            <asp:Parameter Name="Description" Type="String" />
                            <asp:Parameter Name="Body" Type="String" />
                            <asp:Parameter Name="CC" Type="String" />
                            <asp:Parameter Name="Status" Type="Boolean" />
                            <asp:Parameter Name="RefCEUserId" Type="Int64" />
                            <asp:Parameter Name="MakeModelId" Type="Int32" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
